package com.csyaonie.android;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class EditTextActivity extends AppCompatActivity {

    private Button login_bt;
    private EditText et_username;
    private EditText et_password;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_edit_text);
        login_bt=findViewById(R.id.login_bt);
        et_username=findViewById(R.id.et_username);
        et_password=findViewById(R.id.et_password);


        Drawable userDrawable=getResources().getDrawable(R.drawable.user);
        Drawable passwordDrawable=getResources().getDrawable(R.drawable.lock);
        userDrawable.setBounds(0,0,60,60);
        passwordDrawable.setBounds(0,0,60,60);
        et_username.setCompoundDrawables(userDrawable,null,null,null);
        et_password.setCompoundDrawables(passwordDrawable,null,null,null);

        login_bt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });

        et_username.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                Log.d("username:",s.toString());
            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });
    }
}